﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Data;
using Matrix.Common.Utility;
using Matrix.MaKaYunShang.Model;
using Matrix.MaKaYunShang.DAL;

namespace Matrix.MaKaYunShang.BLL
{
    public partial class DiscountRecordBLL : BaseBLL<DiscountRecordBLL>
    {
        #region 默认方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DiscountRecord model)
        {
            return DiscountRecordDAL.Instance.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DiscountRecord model)
        {
            return DiscountRecordDAL.Instance.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ConsumerId)
        {
            return DiscountRecordDAL.Instance.Delete(ConsumerId);
        }
        /// <summary>
        /// 批量删除一批数据
        /// </summary>
        public bool DeleteList(string ConsumerIdlist)
        {
            return DiscountRecordDAL.Instance.DeleteList(ConsumerIdlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DiscountRecord GetModel(int ConsumerId)
        {
            var ds = DiscountRecordDAL.Instance.GetModel(ConsumerId);
            return ds == null ? null : ServicesHelper.DataSetToIList<DiscountRecord>(ds).ToList()[0];
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<DiscountRecord> GetModelList(string strWhere = null)
        {
            var ds = DiscountRecordDAL.Instance.GetList(strWhere);
            return ServicesHelper.DataSetToIList<DiscountRecord>(ds).ToList();
        }
        #endregion

        #region 扩展方法

        public int GetUserMinusNumber(int consumerId, DateTime strTime, DateTime endTime)
        {
            return DiscountRecordDAL.Instance.GetUserMinusNumber(consumerId, strTime, endTime);
        }

        #endregion
    }
}